<?php
class groupControl extends Control{
    function index(){
      $this->display('group.html');  
    }
    
    function ajax_check_group(){//ajax检查小组是否存在
    if(empty($_GET['name'])){
        exit;
    }
      $groupName=urldecode($_GET['name']);
      $db=M('group');
      $num = $db->where("gname='".$groupName."'")->find();
      if(empty($num)){
          echo 1;
      }else{
          echo 0;
      }
    } 
    
    function createGroup_exe(){//创建小组
    p($_SESSION);exit;
    if(empty($_POST['agreement'])){
        $this->success('小组名称已存在','',10);
    }
      $img=new upload('./upload/group');
      $imginfo=$img->upload();
      $db = M('group');
      $_POST['gimage']=$imginfo[0]['path'];//图片字段
      $_POST['gname']=$_POST['name'];//小组名称
      $_POST['ginfo']=$_POST['description'];//小组说明
      $_POST['gkeyworkd']=$_POST['tags'];//小组关键字
      $_POST['gjiaru']=$_POST['permission'];//允许加入的方式
      if($db->add()){
          $this->success('小组已经创建,请等待管理员审核',__WEB__.'/index/izcool',20);
      }else{
          $this->error('小组创建失败，请稍后重试',__WEB__.'/index/izcool',10);
      }

    }
    
}
